package cn.doit

import java.util
import java.util.Date

import cn.doit.utils.{ConfigUtils, TimeUtils}

import scala.collection.mutable

object SparkTest {
  /**
    * 拼接之后存放的集合
    */
  val result = new util.ArrayList[String]()
  def conbinKeyWorker(list: List[Array[String]], str: String): Unit = {

    list.head.foreach(t => {
      val s = str + "@" + t
      if (!list.tail.isEmpty) {
        conbinKeyWorker(list.tail, s)
      }
    })

    if (list.tail.isEmpty) {
      list(0).foreach(a=>{
        result.add(str+"@"+a)
      })

    }
  }

  def combinKey(arr: Array[String]*): util.ArrayList[String] = {
    val list: List[Array[String]] = arr.toList
    list.head.foreach(a => {
      conbinKeyWorker(list.tail, a)
    })

    result
  }

  def main(args: Array[String]): Unit = {

    val arr1 = Array("All", "source")
    val arr2 = Array("All", "deviceType")
    val arr3 = Array("All", "province")
    val arr4 = Array("All", "ssss")
    val strings: util.ArrayList[String] = combinKey(arr1, arr2,arr3)
    import scala.collection.JavaConversions._
    for(i<-strings){
      println(i)
    }

    /*val list = new util.ArrayList[String]()
    arr1.foreach(a => {
      arr2.foreach(b => {
        arr3.foreach(c => {
          val str = a + "@" + b + "@" + c
//          println(str)
          list.add(str)
        })
      })
    })
  import scala.collection.JavaConversions._
    for(i <- list){
      println(i)
    }*/
  }
}
